import java.io.IOException;
import java.io.Serializable;
import java.util.logging.*;


/**
 * This is the treatment record. 
 * It contains all the information of 
 * the patients current trip to the doctor's office.
 */
public class TreatmentRecord implements Serializable{
	protected String date; //Changed to date to be a string instead of time.  We can use RegEx to get date based on slashes.
	//Under the circumstances that we decide not to use date...
	protected int month;
	
	protected int day;
	
	protected String time; 
	
	protected Patient patient;
	
	protected Doctor doctor;
	
	protected String symptoms;
	
	protected Nurse nurse;
	
	private double bloodPressure;
	
	private double pulse;
	
	private double temperature;
	
	private double height;
	
	private double weight;
	
	private DoctorOrders docOrders;
	
	private String diagnosis;
	
	private static Logger treatmentRecordLog = 
		Logger.getLogger(TreatmentRecord.class.getName());
	
	static{
		ConsoleHandler console = new ConsoleHandler();
		console.setLevel(Level.ALL);
		console.setFormatter(new ThunderDragonHtmlFormatter());
		treatmentRecordLog.addHandler(console);
		treatmentRecordLog.setLevel(Level.ALL);
		
		try {
			FileHandler fh = new FileHandler("TreatmentRecordLog.txt");
			fh.setFormatter(new ThunderDragonHtmlFormatter());
			treatmentRecordLog.addHandler(fh);
		} catch (SecurityException e) {
			
			treatmentRecordLog.severe("Failure: Security exception thrown " +
					"when trying to create a new handler in " +
					"TreatmentRecord.java.");
			e.printStackTrace();
		} catch (IOException e) {
			
			treatmentRecordLog.severe("Failure: I/O exception thrown" +
					" when trying to create a new handler " +
					"in TreatmentRecord.java.");
			e.printStackTrace();
		}
		
	}
	
	/**
	 * Constructor for TreatmentRecord.
	 * @param date int
	 * @param time String
	 * @param doctor Doctor
	 * @param symptoms ArrayList<String>
	 * @param nurse Nurse
	 * @param bloodPressure double
	 * @param pulse double
	 * @param temperature double
	 * @param height double
	 * @param weight double
	 * @param diagnosis ArrayList<String>
	 */
	public TreatmentRecord(Patient patient, String date, String time, Doctor doctor,
			String symptoms, Nurse nurse, double bloodPressure,
			double pulse, double temperature, double height, double weight,
			String diagnosis) {
		
		treatmentRecordLog.entering(this.getClass().getName(), 
				"TreatmentRecord Constructor", new Object[] {
			date, time, doctor, symptoms, nurse, bloodPressure, 
			pulse, temperature, height, weight, diagnosis,
			patient});
		
		this.date = date;
		this.time = time;
		this.doctor = doctor;
		this.symptoms = symptoms;
		this.nurse = nurse;
		this.bloodPressure = bloodPressure;
		this.pulse = pulse;
		this.temperature = temperature;
		this.height = height;
		this.weight = weight;
		this.diagnosis = diagnosis;
		this.patient = patient;
		
		treatmentRecordLog.exiting(this.getClass().getName(), 
				"TreatmentRecord Constructor");
	}
	
	/*
	 * IMPORTANT!  THIS IS A NEW CONSTRUCTOR I USED TO FOLLOW 
	 * WITH THE CURRENT TREATMENTRECORDPANEL!
	 * It is designed to follow with the 'month' and 'day' blocks presented.  \
	 * Just in case you want to use this idea over the previous one Zipp.
	 */
	
/**
 * 
 * @param patient
 * @param month
 * @param day
 * @param time
 * @param doctor
 * @param symptoms
 * @param nurse
 * @param bloodPressure
 * @param pulse
 * @param temperature
 * @param height
 * @param weight
 * @param diagnosis
 */
	public TreatmentRecord(Patient patient, int month, int day, String time, Doctor doctor,
			String symptoms, Nurse nurse, double bloodPressure,
			double pulse, double temperature, double height, double weight,
			String diagnosis){
		
		this.patient = patient;
		this.month = month;
		this.day = day;
		this.time = time;
		this.doctor = doctor;
		this.symptoms = symptoms;
		this.nurse = nurse;
		this.bloodPressure = bloodPressure;
		this.pulse = pulse;
		this.temperature = temperature;
		this.height = height;
		this.weight = weight;
	}
	
	


	/**
	 * Method getDate.
	 * @return int
	 */
	public String getDate() {
		treatmentRecordLog.finest("Called getDate() in class TreatmentRecord.");
		return date;
	}

	/**
	 * Method setDate.
	 * @param date int
	 */
	public void setDate(String date) {
		this.date = date;
		treatmentRecordLog.finest("Called setDate() in class TreatmentRecord.");
	}
	
	/*THIS WAS ADDED RECENTLY BY MATT LEE.  MONTHS AND DAYS
	 * TO CORRESPOND WITH THE TREATMENTRECORDPANEL. 4/27/2011*/
	
	/**
	 * Returns the month.
	 * @return the month set.
	 */
	public int getMonth() {
		return month;
	}

	/**
	 * Sets the specified month.
	 * @param month
	 */
	public void setMonth(int month) {
		this.month = month;
	}

	/**
	 * Returns the day.
	 * @return the specified day.
	 */
	public int getDay() {
		return day;
	}

	public void setDay(int day) {
		this.day = day;
	}
	
	/**
	 * Method getTime.
	 * @return int
	 */
	public String getTime() {
		treatmentRecordLog.finest("Called getTime() in class TreatmentRecord.");
		return time;
	}

	/**
	 * Method setTime.
	 * @param time int
	 */
	public void setTime(String time) {
		this.time = time;
		treatmentRecordLog.finest("Called setTime() in class TreatmentRecord.");
	}

	/**
	 * Method getDoctor.
	 * @return Doctor
	 */
	public Doctor getDoctor() {
		treatmentRecordLog.finest("Called getDoctor() in class TreatmentRecord.");
		return doctor;
	}

	/**
	 * Method setDoctor.
	 * @param doctor Doctor
	 */
	public void setDoctor(Doctor doctor) {
		this.doctor = doctor;
		treatmentRecordLog.finest("Called setDoctor() in class TreatmentRecord.");
	}

	/**
	 * Method getNurse.
	 * @return Nurse
	 */
	public Nurse getNurse() {
		treatmentRecordLog.finest("Called getNurse() in class TreatmentRecord.");
		return nurse;
	}

	/**
	 * Method setNurse.
	 * @param nurse Nurse
	 */
	public void setNurse(Nurse nurse) {
		this.nurse = nurse;
		treatmentRecordLog.finest("Called setNurse() in class TreatmentRecord.");
	}

	/**
	 * Method getPatient.
	 * @return Patient.
	 */
	public Patient getPatient(){
		return this.patient;
	}

	/**
	 * Method setPatient.
	 * @param patient Patient.
	 */
	public void setPatient(Patient patient){
		this.patient = patient;
	}

	/**
	 * Method getSymptoms.
	 * @return ArrayList<String>
	 */
	public String getSymptoms() {
		treatmentRecordLog.finest("Called getSymptoms() in class TreatmentRecord.");
		return symptoms;
	}

	/**
	 * Method setSymptoms.
	 * @param symptoms ArrayList<String>
	 */
	public void setSymptoms(String symptoms) {
		this.symptoms = symptoms;
		treatmentRecordLog.finest("Called setSymptoms() in class TreatmentRecord.");
	}

	/**
	 * Method getBloodPressure.
	 * @return double
	 */
	public double getBloodPressure() {
		treatmentRecordLog.finest("Called getBloodPressure() in class TreatmentRecord.");
		return bloodPressure;
	}

	/**
	 * Method setBloodPressure.
	 * @param bloodPressure double
	 */
	public void setBloodPressure(double bloodPressure) {
		this.bloodPressure = bloodPressure;
		treatmentRecordLog.finest("Called setBloodPressure() in class TreatmentRecord.");
	}

	/**
	 * Method getPulse.
	 * @return double
	 */
	public double getPulse() {
		treatmentRecordLog.finest("Called getPulse() in class TreatmentRecord.");
		return pulse;
	}

	/**
	 * Method setPulse.
	 * @param pulse double
	 */
	public void setPulse(double pulse) {
		this.pulse = pulse;
		treatmentRecordLog.finest("Called setPulse() in class TreatmentRecord.");
	}

	/**
	 * Method getTemperature.
	 * @return double
	 */
	public double getTemperature() {
		treatmentRecordLog.finest("Called getTemperature() in class TreatmentRecord.");
		return temperature;
	}

	/**
	 * Method setTemperature.
	 * @param temperature double
	 */
	public void setTemperature(double temperature) {
		this.temperature = temperature;
		treatmentRecordLog.finest("Called setTemperature() in class TreatmentRecord.");
	}

	/**
	 * Method getHeight.
	 * @return double
	 */
	public double getHeight() {
		treatmentRecordLog.finest("Called getHeight() in class TreatmentRecord.");
		return height;
	}

	/**
	 * Method setHeight.
	 * @param height double
	 */
	public void setHeight(double height) {
		this.height = height;
		treatmentRecordLog.finest("Called setHeight() in class TreatmentRecord.");
	}

	/**
	 * Method getWeight.
	 * @return double
	 */
	public double getWeight() {
		treatmentRecordLog.finest("Called getWeight() in class TreatmentRecord.");
		return weight;
	}

	/**
	 * Method setWeight.
	 * @param weight double
	 */
	public void setWeight(double weight) {
		this.weight = weight;
		treatmentRecordLog.finest("Called setWeight() in class TreatmentRecord.");
	}

	/**
	 * Method getDocOrders.
	 * @return DoctorOrders
	 */
	public DoctorOrders getDocOrders() {
		treatmentRecordLog.finest("Called getDocOrders() in class TreatmentRecord.");
		return docOrders;
	}

	/**
	 * Method setDocOrders.
	 * @param docOrders DoctorOrders
	 */
	public void setDocOrders(DoctorOrders docOrders) {
		this.docOrders = docOrders;
		treatmentRecordLog.finest("Called setDocOrders() in class TreatmentRecord.");
	}

	/**
	 * Method getDiagnosis.
	 * @return String
	 */
	public String getDiagnosis() {
		treatmentRecordLog.finest("Called getDiagnosis() in class TreatmentRecord.");
		return diagnosis;
	}

	/**
	 * Method setDiagnosis.
	 * @param diagnosis String
	 */
	public void setDiagnosis(String diagnosis) {
		this.diagnosis = diagnosis;
		treatmentRecordLog.finest("Called setDiagnosis() in class TreatmentRecord.");
	}

	@Override
	public String toString() {
		return "TreatmentRecord [date=" + date + ", time=" + time
				+ ", patient=" + patient + ", doctor=" + doctor + ", symptoms="
				+ symptoms + ", nurse=" + nurse + ", bloodPressure="
				+ bloodPressure + ", pulse=" + pulse + ", temperature="
				+ temperature + ", height=" + height + ", weight=" + weight
				+ ", docOrders=" + docOrders + ", diagnosis=" + diagnosis + "]";
	}
	
	
}
